package handle

import (
	"github.com/gin-gonic/gin"
	"school-hub/model"
)

func Create(c *gin.Context) {
	title := c.PostForm("title")
	content := c.PostForm("content")
	img := c.PostForm("img")
	school := model.School{
		Title:   title,
		Content: content,
		Img:     img,
	}
	model.DB.Create(&school)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
func List(c *gin.Context) {
	var school []model.School
	model.DB.Find(&school)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "查找成功",
		"data": school,
	})

}
